<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>定制任务</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="icon" href="../homepage/img/logo.png">
    <link rel="stylesheet" href="../public/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../public/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
        .layui-form-item .layui-form-label{
            font-size: 15px;
            width: 90px;
        }
        .layui-btn{
            background-color: #86a0f3;
        }
        .layui-form-checked span, .layui-form-checked:hover span {
            background-color: #86a0f3
        }
        .layui-form-radio>i:hover, .layui-form-radioed>i {
            color: #86a0f3
        }
        .layui-form-checked i, .layui-form-checked:hover i {
            color: #86a0f3
        }
        .layui-input-block {
            margin-left: 10px;
        }
    </style>
</head>
<body>
<form class="layui-form" method="post" action="" enctype="multipart/form-data">
    <div class="layui-form-item" >
        <div class="layui-col-md3  layui-input-block " id="receiver" style="margin-left: 10px">
<!--            <input type="checkbox" name="10008" title="老师3">-->
<!--            <input type="checkbox" name="19" title="19级" >-->
<!--            <input type="checkbox" name="20" title="20级" >-->
<!--            <input type="checkbox" name="20" title="20级" >-->
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveBtn" id="saveBtn">确认添加</button>
            <button type="reset" class="layui-btn layui-btn-primary" style="color: white;">重置</button>
        </div>
    </div>
</form>
<script src="../public/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['upload','form', 'layedit', 'laydate', 'layer'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , upload = layui.upload;
        $ = layui.$;

        $('#saveBtn').on('click', function (event) {
            event.preventDefault()
            let recivers = []
            let teacher=[]
            $.each($('input[type=checkbox]:checked'), function (index, item) {
                // console.log(index);
                console.log(item.name);
                teacher.push(item.name);
                recivers.push(parseInt(item.value))
            })
            localStorage.setItem('teacher',teacher);
            localStorage.setItem('recivers', recivers)
        })
    });
</script>
<script src="../public/jquery-1.12.4.js"></script>
<script>

    $.ajax({
        //url:'../api/receiver.json',
        url:'/Counselor_System/manage/selectAllName',
        type:'GET',
        dataType:'json',
        success:function (res) {
            if(res.code == 0){
                var data=res.data;
                console.log(data)
                var Is=$('#receiver')
                var content = ''
                for (var i in data) {
                    content +='<input type="checkbox" value="'+ data[i].id+'" name="'+ data[i].name+'" title="'+data[i].name+'">' +
                        '<div class="layui-unselect layui-form-checkbox"><span>'+data[i].name+'</span><i class="layui-icon layui-icon-ok"></i></div>'
                }
                Is.html(content);
            }
        },
        error:function (res) {
            console.log(res)
        }
    });
    var Is=$('input[type=checkbox]');
    console.log(Is.val());
</script>

</body>
</html>